package com.luguokong.pet_rescue.service;


import com.luguokong.pet_rescue.mapper.AdoptMapper;
import com.luguokong.pet_rescue.pojo.Adopt;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

@Service
public class AdoptService {

    @Autowired
    private AdoptMapper adoptMapper;

    public int insertAdopt(Adopt adopt){
        int i = adoptMapper.insertAdopt(adopt);
        return i;
    }
    public int deleteAdoptById(int adopt_id){
        int i = adoptMapper.deleteAdoptById(adopt_id);
        return i;
    }
    public int updateAdoptById(Adopt adopt){
        int i = adoptMapper.updateAdoptById(adopt);
        return i;
    }
    public Adopt selectAdoptById(int adopt_id){
        Adopt adopt = adoptMapper.selectAdoptById(adopt_id);
        return adopt;
    }
    public List<Adopt> selectAdoptAll(){
        List<Adopt> adoptList = adoptMapper.selectAdoptAll();
        return adoptList;
    }
    public List<Adopt> selectAdoptAllByUserId(int user_id){
        List<Adopt> adoptList = adoptMapper.selectAdoptAllByUserId(user_id);
        return adoptList;
    }

    public List<Adopt> selectAdoptAllByPageNumByPageSize(int pageNum, int pageSize){
        List<Adopt> adoptList = adoptMapper.selectAdoptAllByPageNumByPageSize(pageNum, pageSize);
        return adoptList;
    }

    public int selectDataCount(){
        int i = adoptMapper.selectDataCount();
        return i;
    }

    //    查询每个宠物类型的领养数量
    public List<Map<String, Number>> selectGroupByPetType(){
        List<Map<String, Number>> mapList = adoptMapper.selectGroupByPetType();
        return mapList;
    }



}
